package com.hengfoxwolf.kiuilp
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.recyclerview.widget.GridLayoutManager
import com.hengfoxwolf.commonbase.base.BaseActivity2
import com.hengfoxwolf.commonbase.base.databeans.DataFactory
import com.hengfoxwolf.kiuilp.adapter.DataUseAdapter
import com.hengfoxwolf.kiuilp.databinding.KiuilpActivityMainBinding

class KiuilpActivity :
    BaseActivity2<KiuilpActivityMainBinding>(KiuilpActivityMainBinding::inflate) {

    override fun preInit() {
        //enableEdgeToEdge()
    }

    override fun init(savedInstanceState: Bundle?) {
        //ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
        //    val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
        //    v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
        //    insets
        //}

        val dataSet = DataFactory.createCharStr(28)
        //kiuilp_dp10与kiuilp_dp5_相对应 正负值的一半 弥补DataItemDecoration边距值间隙
        val space = resources.getDimension(R.dimen.kiuilp_dp10).toInt()
        val spanCount = 5
        mBinding.rvData.apply {
            layoutManager = GridLayoutManager(this@KiuilpActivity, spanCount)
            adapter = DataUseAdapter().apply {
                itemDataSet = dataSet
            }
            addItemDecoration(DataItemDecoration(space, spanCount))
        }
    }

}